package java6681.lesson10;

import java.util.Scanner;

public class Counter {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        System.out.println("请输入原字符串：");
        String st = sc.next();
        System.out.println("请输入指定字符串：");
        String m = sc.next();
        System.out.println("请输入指定字符：");
        char c = sc.next().charAt(0);
        System.out.println(count6681(st,m));
        System.out.println(count6681(st,c));
    }
    public static int count6681(String st,String m) {
        int count = 0;
        while(st.indexOf(m)>=0) {
            st=st.substring(st.indexOf(m)+m.length());
            count++;
        }
        return count;
    }
  public static int count6681(String st,char M){
        int count = 0;
        for (int i = 0; i < st.length(); i++) {
            char ch = st.charAt(i);
            if (ch == M){
                count++;
            }
        }
        return count;
    }

}
